<template>
  <array-com
    :pop-width="800"
    :get-add-data-fun="getAddDataFunc"
    @addClick="initAddData"
    @edit-click="editClick"
  >
    <template slot="add">
      <jsone-eitor ref="JsonEditer"/>
    </template>
  </array-com>
</template>

<script lang="ts">
  import ArrayCom from '@/components/data/array/index.vue'
  import { Vue, Component } from 'vue-property-decorator'
  import YBPopView from "@/utils/popView";
  import JsoneEitor from '@/components/global/jsoneditor/index.vue'
  import {JsonEditerType} from "@/components/global/jsoneditor/types";
  import DataModel from "@/models/DataModel";

  @Component({
    components: {
      ArrayCom,
      JsoneEitor
    }
  })
  export default class JSONDataModel extends Vue {

    initAddData(data?: string) {
      this.$nextTick(() => {
        (this.$refs.JsonEditer as JsonEditerType).setData(data);
      })
    }

    editClick(model: DataModel) {
      this.initAddData(model.data)
    }

    getAddDataFunc() {
      return (this.$refs.JsonEditer as JsonEditerType).getData()
    }

    mounted() {
    }
  }

</script>

<style lang="scss">

</style>
